package com.zhida.chatservice.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.zhida.chatservice.service.IMessageService;
import com.zhida.common.entity.Result;
import com.zhida.common.utils.TokenProcessor;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ling
 * @since 2024-07-19
 */
@RestController
@RequestMapping("/message")
public class MessageController {

    @Resource
    IMessageService messageService;

    @GetMapping("/backupUserMessage")
    public Result<?> backupUserMessage(){
        return messageService.backupUserMessage();
    }

    @GetMapping("/backupGroupMessage")
    public Result<?> backupGroupMessage() {
        return messageService.backupGroupMessage();
    }

    @GetMapping("/getMessage/{to}/{current}/{pageSize}")
    public Result<?> getMessage(@PathVariable String to,@PathVariable Integer current, @PathVariable Integer pageSize) {
        return messageService.getMessage(to,current,pageSize);
    }

    @RequestMapping("/getOfflineMsg")
    public Result<?> getOfflineMsg() throws JsonProcessingException {
        return messageService.getOfflineMsg();
    }

}
